import React from 'react'

interface Iprops {
    count: number,
    increment: ()=>void,
    decrement: ()=>void,
    title?: string // 如果需要title在父组件中可传可不传，需要添加？
}
/*
const Counter = (props: Iprops)=>{
    return (
        <>
            <h1>0</h1>
            <button onClick={props.increment}>increment</button>
            <button>decrement</button>
        </>
    )
}
*/
// 对上面的函数参数进行解构  参数验证
const Counter = ({count, increment, decrement}: Iprops)=>{
    return (
        <>
            <h1>{count}</h1>
            <button onClick={increment}>increment</button>
            <button onClick={decrement}>decrement</button>
        </>
    )
}

export default Counter;
